package cn.gdsdxy.controller;

import cn.gdsdxy.pojo.Appraise;
import cn.gdsdxy.service.AppraiseService;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@ResponseBody
public class AppraiseController {
    @Autowired
    AppraiseService appraiseService;
        @GetMapping("/app/goodsid/{id}")
    public String getidappraise(@PathVariable("id") int id){
        String Appraise= JSON.toJSONString(appraiseService.getidappraise(id));
        return Appraise;
//        return  bookService.getAllBook().toString();
    }
    @PutMapping("/addAppraise")
    public String addAppraise(@RequestBody Appraise appraise){//@RequsetBody将从前端传递过来的JSON数据转化成Book对象1
        if(appraiseService.addAppraise(appraise)>0)
            return "success";
        else
            return "fail";
    }
}
